//
//  STOrderPriceOverView.m
//  YiYueStore
//
//  Created by zhouzhouzhou on 2018/9/28.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STOrderPriceOverView.h"
#import "YLHomeOrderListModel.h"
@implementation STOrderPriceOverView


-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    //加载用户信息
    if (self) {
        self.autoresizesSubviews = NO;
        STOrderPriceOverView * userView =  [[NSBundle mainBundle] loadNibNamed:@"STOrderPriceOverView"owner:self options:nil].lastObject;
        self = userView;
        self.frame = frame;
    }
    return self;
}

-(void)setOrderPriceOverWithType:(int)type data:(id)data{
    YLHomeOrderListModel * listModel = data;

    if (type == 0){
        if ([listModel.status intValue] == 13 || [listModel.status intValue] == 14 || [listModel.status intValue] == 15 || [listModel.status intValue] == 3) {
            self.hidden = YES;
        }else if ([listModel.status intValue] == 8){
            self.totalNameLab.hidden = YES;
            self.totalPriceLab.hidden = YES;

            self.priceNameLab.text = @"当前申请：";
            self.proPriceLab.text = @"服务加价";
            self.priceNameLab.textColor = [UIColor greenColor];
            self.proPriceLab.textColor = [UIColor greenColor];
            
            self.addPriceNameLab.text = @"服务加价：";
            self.servicePriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAddMoney.addmoney];
            
            self.contentNameLab.text = @"加价原因：";
            self.contentLab.text = listModel.orderAddMoney.adddesc;
            
        }
        
    }else if(type == 1){
        if ([listModel.status intValue] == 4){
            self.hidden = YES;
        }else if ([listModel.status intValue] == 7){
            
            self.priceNameLab.text = @"项目价格：";
            self.proPriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAmount];
            self.priceNameLab.textColor = [UIColor greenColor];
            self.proPriceLab.textColor = [UIColor greenColor];
            
            self.addPriceNameLab.text = @"服务加价：";
            self.servicePriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAddMoney.addmoney];
            
            self.totalNameLab.hidden = YES;
            self.totalPriceLab.hidden = YES;
            self.contentNameLab.text = @"服务价格：";
            self.contentLab.text = @"服务价格 = (项目价格+服务加价)*85%";
        }
        
    }else if (type == 2 ){
        if ([listModel.status integerValue] == 11) {//未评价
            self.priceNameLab.text = @"项目价格：";
            self.proPriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAmount];
            self.priceNameLab.textColor = [UIColor greenColor];
            self.proPriceLab.textColor = [UIColor greenColor];
            
            self.addPriceNameLab.text = @"服务加价：";
            self.servicePriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAddMoney.addmoney];
            float  total = [listModel.orderAddMoney.addmoney floatValue]+[listModel.orderAmount floatValue];
            NSString * totalStr = [NSString stringWithFormat:@"%.2f",total];
            
            self.totalNameLab.hidden = NO;
            self.totalPriceLab.hidden = NO;
            self.contentNameLab.text = @"加价原因：";
            self.contentLab.text = listModel.orderAddMoney.adddesc;
            self.totalNameLab.text = @"服务总计：";
            self.totalPriceLab.text = [NSString stringWithFormat:@"¥%@",totalStr];
        }else if ([listModel.status integerValue] == 18){//已评价
            self.contentNameLab.hidden = YES;
            self.contentLab.hidden = YES;
            
            self.priceNameLab.text = @"项目价格：";
            self.proPriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAmount];
            self.priceNameLab.textColor = [UIColor greenColor];
            self.proPriceLab.textColor = [UIColor greenColor];
            
            self.addPriceNameLab.text = @"服务加价：";
            self.servicePriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAddMoney.addmoney];
            float  total = [listModel.orderAddMoney.addmoney floatValue]+[listModel.orderAmount floatValue];
            NSString * totalStr = [NSString stringWithFormat:@"%.2f",total];
            
            self.totalNameLab.hidden = NO;
            self.totalPriceLab.hidden = NO;
            self.totalNameLab.text = @"服务总计：";
            self.totalPriceLab.text = [NSString stringWithFormat:@"¥%@",totalStr];
        }
        
        
    }else if (type == 3 ){
        self.totalNameLab.hidden = YES;
        self.totalPriceLab.hidden = YES;

        self.priceNameLab.text = @"项目价格：";
        self.proPriceLab.text = [NSString stringWithFormat:@"¥%@",listModel.orderAmount];
        
        self.addPriceNameLab.text = @"退回金额：";
        self.servicePriceLab.text = listModel.orderRefund.refundamount;
        
        self.contentNameLab.text = @"手续费：";
        self.contentLab.text = listModel.orderRefund.handlingfee;
        self.contentLab.textColor = [UIColor yellowColor];
        self.refundRemarkLab.text = @"（项目价格的5%）";
    }
}
/*
 if (type == 0 || type == 1 ) {
 self.totalNameLab.hidden = YES;
 self.totalPriceLab.hidden = YES;
 
 self.dayLab.hidden = NO;
 
 self.priceNameLab.text = @"当前申请：";
 self.proPriceLab.text = @"取消订单";
 self.priceNameLab.textColor = [UIColor greenColor];
 self.proPriceLab.textColor = [UIColor greenColor];
 
 self.addPriceNameLab.text = @"预约时间：";
 self.servicePriceLab.text = @"2018-09-11 22：36";
 self.dayLab.text = @"(明天)";
 
 self.contentNameLab.text = @"申请原因：";
 self.contentLab.text = @"明天临时有事 行个方便";
 
 }
 else if (type == 4 || type == 6|| type == 7){
 if (self) {
 [self removeFromSuperview];
 }
 }

 */
@end
